<?php

namespace App\Http\Controllers\Backend;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\HeadStore;
use App\Transformers\HeadStoreTransformer;

class HeadStoreController extends Controller
{
    /**
     * 主店铺列表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function index(Request $request) {
        $head_store = $request->user();
        $head_stores = HeadStore::paginate(10);
        $data['data'] = [
          'head_stores' => $this->factalPaginator($head_stores, new HeadStoreTransformer())
        ];
        return $this->apiSuccess($data);
    }

    /**
     * 写死的新建主店铺
     * @param Request $request
     */
    public function create(Request $request) {
        HeadStore::create(['name' => '大闸蟹', 'address' => '阳澄湖', 'account' => 'bigzhaxie', 'password' => bcrypt('123456'), 'description' => '12312313']);
    }

    private function validateCreateHeadStore($input) {
        $name = isset($input['name']) ? $input['name']: '';
        $address = isset($input['address']) ? $input['address']: '';
        $account = isset($input['account']) ? $input['account']: '';
        $address = isset($input['address']) ? $input['address']: '';
        $address = isset($input['address']) ? $input['address']: '';
        if(!empty($mobile)){
            return [
                "message" => "手机格式有误",
                "errorCode" => 5000
            ];
        }

        return [
            "message" => "没有错误信息",
            "errorCode" => 0
        ];

    }
}
